package com.yj.result;

import lombok.Data;

@Data
public class ReturnResp<T> {


    private boolean success;

    private Integer code;

    private String message;

    private T data;

    public static <T> ReturnResp success() {

        return success(200, "success", null);
    }

    public static <T> ReturnResp success(Integer code) {

        return success(code, "success", null);
    }

    public static <T> ReturnResp success(String message) {

        return success(200, message, null);
    }

    public static <T> ReturnResp success(Integer code, String message) {

        return success(code, message, null);
    }

    public static <T> ReturnResp success( T data) {

        return success(200, "success", data);
    }

    public static <T> ReturnResp success(String message, T data) {

        return success(200, message, data);
    }

    public static <T> ReturnResp success(Integer code, String message, T data) {
        ReturnResp returnResp = new ReturnResp();
        returnResp.setSuccess(true);
        returnResp.setCode(code);
        returnResp.setMessage(message);
        returnResp.setData(data);
        return returnResp;
    }

    public static <T> ReturnResp fail() {

        return fail(500, "fail", null);
    }

    public static <T> ReturnResp fail(Integer code) {

        return fail(code, "fail", null);
    }

    public static <T> ReturnResp fail(String message) {

        return fail(500, message, null);
    }

    public static <T> ReturnResp fail(T data) {

        return fail(500, "fail", data);
    }

    public static <T> ReturnResp fail(Integer code, String message) {

        return fail(code, message, null);
    }


    public static <T> ReturnResp fail(String message, T data) {

        return fail(500, message, data);
    }

    public static <T> ReturnResp fail(Integer code, String message, T data) {
        ReturnResp returnResp = new ReturnResp();
        returnResp.setSuccess(true);
        returnResp.setCode(code);
        returnResp.setMessage(message);
        returnResp.setData(data);
        return  returnResp;
    }
}
